﻿@using  Aguacongas.IdentityServer.Store
@inherits AutoCompleteModel<Entity.ClientIdpRestriction>
@inject IAdminStore<Entity.ExternalProvider>  _store

@if (IsReadOnly)
{
    <div class="input-group input-group-sm mb-3">
        <a href="/externalprovider/@Entity.Provider" class="form-control" disabled>@_providerName</a>
        <div class="input-group-append select" @onclick="() => DeleteClicked.InvokeAsync(null)">
            <span class="input-group-text oi oi-trash" />
        </div>
    </div>   
}
else
{
    <div id="@Id" class="input-group input-group-sm mb-3" data-bs-toggle="dropdown">
        <input type="text" class="form-control new-claim" placeholder="@Localizer["provider"]" value="@CurrentValue"
               @oninput="OnInputChanged" @onfocus="Filter" />
        <div class="input-group-append">
            <span class="input-group-text oi oi-plus" />
        </div>
    </div>
    <div class="dropdown-menu m-0">
        @if (_filteredProviders != null)
        {
            foreach (var provider in _filteredProviders)
            {
                <button class="dropdown-item m-0 p-0 pl-1 pr-1" type="button" @onclick="() => SetSelectedValue(provider.Id)">
                    <small>@provider.DisplayName</small>
                    <div class="text-muted font-italic">
                        <small>@provider.Id</small>
                    </div>
                </button>
            }
        }
    </div>
}
